<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>后台登录-X-admin1.1</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="../x-admin/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="../x-admincss/font.css">
    <link rel="stylesheet" href="../x-admin/css/xadmin.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/Swiper/3.4.2/css/swiper.min.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/Swiper/3.4.2/js/swiper.jquery.min.js"></script>
    <script src="../x-admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../x-admin/js/xadmin.js"></script>

</head>
<body>
<!-- 中部开始 -->
<div class="wrapper">
    <!-- 右侧主体开始 -->
    <div class="page-content">
        <div class="content">
            <!-- 右侧内容框架，更改从这里开始 -->
            <form class="layui-form"  id="myform"  method="post" enctype="multipart/form-data">
                <div class="layui-form-item">
                    <label for="L_username" class="layui-form-label">
                        用户ID
                    </label>

                    <div class="layui-input-inline">
                        <input type="text" id="L_username" disabled name="oldpass" value="${admin.adminid}" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_username" class="layui-form-label">
                        用户名
                    </label>

                    <div class="layui-input-inline">
                        <input type="text" id="L_username" name="uname" value="${admin.adminaccount}" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_pass" class="layui-form-label">
                        密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" id="L_pass" name="pass" value="${admin.adminpwd}" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                        是否可用
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="L_repass" disabled name="repass" value="${admin.adminstate}" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                    </label>
                    <input type="submit"  class="layui-btn" value="修改" lay-filter="save">
                    <button type="button"  class="layui-btn" onclick="recurrence()">
                        返回
                    </button>
                </div>
            </form>
            <!-- 右侧内容框架，更改从这里结束 -->
        </div>
    </div>
    <!-- 右侧主体结束 -->
</div>
<!-- 中部结束 -->
<script>
    onload = function (){
        let  fome = document.querySelector("#myform");

        fome.addEventListener("submit",function (){
            let formData = new FormData(document.querySelector("#myform"));
            //    阻止表单提交
            event.preventDefault();
            $.ajax({
                url:"/message",
                type:"post",
                data: formData,
                //processData表示ajax提交的时候是否会对data参数进行序列化。false表示不会
                processData: false,
                //  processData: false,不要将表单的数据变成字符串
                /*
                * 默认编码方式application/x-www-form-urlencoded
                * 文件上传设置的编码方式multipart/form-data
                * contentType设置成false，表示ajax上传的时候不会对编码进行修改
                * */
                contentType:false,
                success:function(resp){
                   alert("修改成功");
                   location.href="/htindex";
                }
            })
        })
    }


    function recurrence(){
        location.href="/htindex"
    }
</script>
</body>
</html>